/*
 * @Description:
 * @Autor: fage
 * @Date: 2022-07-25 17:41:49
 * @LastEditors: chenbinfa
 * @LastEditTime: 2022-09-07 14:54:10
 * @description: 描述信息
 * @author: chenbinfa
 */
import React, { useRef, useState, useEffect } from "react";
import { DatePicker, Input, InputNumber, Menu, Modal, Button, Dropdown, Descriptions, Select, Space, Table, message, Tabs, Popconfirm, Checkbox, Card, Form } from "antd";
import { UserOutlined, DownOutlined, DeleteOutlined, SwapRightOutlined } from "@ant-design/icons";
import _ from "lodash";
import { useNavigate } from "react-router-dom";
import "./ThTable.less";

const { Option } = Select;
const { Column, ColumnGroup } = Table;
const { TabPane } = Tabs;
const { RangePicker } = DatePicker;
const { TextArea } = Input;
let runCount = 0;
let dics = [];

export function ThForm({ props, detailInfo }) {
	runCount++;
	console.log("ThForm render count", runCount);
	const onFinish = values => {
		console.log("Success:", values);
	};

	const onFinishFailed = errorInfo => {
		console.log("Failed:", errorInfo);
	};
	const formProps = props.create.formProps;
	return (
		<Form
			{...formProps}
			name="basic"
			labelCol={{
				span: 4
			}}
			wrapperCol={{
				span: 20
			}}
			initialValues={detailInfo}
			onFinish={onFinish}
			onFinishFailed={onFinishFailed}
			autoComplete="off">
			{props.create.columns.map((t, index) => {
				return (
					<Form.Item {...t.formItemProps} key={index}>
						{t.showType == "text" ? (
							<Input {...t.inputProps} />
						) : t.showType == "password" ? (
							<Input.Password {...t.inputProps} />
						) : t.showType == "checkbox" ? (
							<Checkbox {...t.inputProps}></Checkbox>
						) : (
							""
						)}
					</Form.Item>
				);
			})}

			<Form.Item
				wrapperCol={{
					offset: 8,
					span: 16
				}}>
				<Button type="primary" htmlType="submit">
					Submit
				</Button>
			</Form.Item>
		</Form>
	);
}
